import  request  from "../../utils/request"

Page({ 
  /**
   * 页面的初始数据
   */
  data: {
      bannerList:[],//轮播图
      personalized:[],//推荐歌单
      topListData:[]//排行榜数据
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: async function (options) {
  let bannerList = await request('/banner',{type:2});
   this.setData({
    bannerList :bannerList.banners
   })
   let  personalizedData = await request('/personalized',{limit:30})
  this.setData({
    personalized : personalizedData.result
  })
  let hotArr = [];
   // 新歌榜
   let topListData =await request('/playlist/detail',{id:3779629})
   let topListItem = {name:topListData.playlist.name,tracks:topListData.playlist.tracks.slice(0,3)};
   hotArr.push(topListItem)
    // 热歌榜
  let regeData = await request('/playlist/detail',{id:3778678})
  let regeItem = {name:regeData.playlist.name,tracks:regeData.playlist.tracks.slice(3,6)};
  hotArr.push(regeItem)
  this.setData({
    topListItem : hotArr
  })
  },
  toRecommend(){
    wx.navigateTo({
      url: '/pages/recommend/recommend'
    });
  },
  /** 
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})